package com.chen.common;

/**
 * @Author:chenao
 * @DATE:2022/3/10 22:51
 */
public enum Constant {
    STATUS_OPEN("启用", "1"),
    STATUS_CLOSE("禁用", "0"),
    DEFAULT_PASSWORD("默认密码","system123"),
    ROLE_COMMON("普通管理员","common"),
    ROLE_ROOT("超级管理员","root"),
    ROLE_SYSTEM("系统管理员","system"),
    COACH_AVATAR_MALE("默认头像","http://localhost:8889/app/img/coach/male.jpg"),
    COACH_AVATAR_FEMALE("默认头像","http://localhost:8889/app/img/coach/female.jpg");

    private String name;
    private String value;

    Constant(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getname() {
        return name;
    }

    /**
     * 通过值获取name属性
     * @param value
     * @return
     */
    public static String getname(String value) {
        for (Constant constant : Constant.values()) {
            if (constant.value.equals(value)){
                return constant.getname();
            }
        }
        try {
            throw new Exception("未找到该值对应的变量");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public void setname(String name) {
        this.name = name;
    }

    public String getvalue() {
        return value;
    }

    /**
     * 通过name获取value属性
     * @param name
     * @return
     */
    public static String getvalue(String name) {
        return Constant.valueOf(name).value;
    }

    public void setvalue(String value) {
        this.value = value;
    }
}

